
from flask_sqlalchemy import SQLAlchemy

db = SQLAlchemy()

import datetime


# 用户表：
class UserModel(db.Model):
    id = db.Column(db.Integer,primary_key=True,autoincrement=True,comment='用户ID')
    username = db.Column(db.String(32),comment='用户名')
    password = db.Column(db.String(32),comment='用户密码')
    mobile = db.Column(db.String(16),comment='手机号')
    img = db.Column(db.String(128),comment='头像')
    time = db.Column(db.DateTime,default=datetime.datetime.now,comment='登录时间')
    totle = db.Column(db.Integer,comment='总金额')
    inqu = db.relationship('InquiryModel',backref = 'user')
    cat = db.relationship('CatModel',backref = 'userl')



# 医生模型类：
class DoctorModel(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True, comment='医生ID')
    img = db.Column(db.String(128),comment='医生头像')
    name = db.Column(db.String(32),comment='医生姓名')
    cong_ye = db.Column(db.String(32),comment='从业')
    inq = db.relationship('InquiryModel',backref='doct')
    wen = db.relationship('WenModel',backref = 'doctz')




class InquiryModel(db.Model):
    id = db.Column(db.Integer,primary_key=True,autoincrement=True,comment='医生ID')
    be_good_at = db.Column(db.String(128),comment='擅长')
    answer_num = db.Column(db.Integer,comment='解答次数')
    synth = db.Column(db.DECIMAL(10,1),comment='综合评分')
    fans_num = db.Column(db.Integer,comment='粉丝数据')
    brief = db.Column(db.String(150),comment='个人简介')
    territory = db.Column(db.String(150),comment='擅长领域')
    hospital_img = db.Column(db.String(128),comment='医院图片')
    hospital_name = db.Column(db.String(32),comment='医院名')
    hospital_addr = db.Column(db.String(120),comment='医院地址')
    evaluate = db.Column(db.Text,comment='评价')
    user_id = db.Column(db.Integer,db.ForeignKey('user_model.id'))
    doctor_id = db.Column(db.Integer,db.ForeignKey('doctor_model.id'))



#  猫模型：
class CatModel(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True, comment='猫ID')
    name = db.Column(db.String(32),comment='猫名字')
    img = db.Column(db.String(128),comment='猫图片')
    month = db.Column(db.String(32),comment='年龄')
    kind = db.Column(db.String(32),comment='种类')
    addr = db.Column(db.String(32),comment='地址')
    wen_zhen = db.relationship('WenModel',backref='cat')
    user_id = db.Column(db.Integer,db.ForeignKey('user_model.id'))



# 问诊表：
class WenModel(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True, comment='问诊ID')
    one = db.Column(db.Boolean,comment='1年')
    ther = db.Column(db.Boolean,comment='3个月')
    ster = db.Column(db.Boolean,comment='绝育')
    desc = db.Column(db.Text,comment='症状描述')
    doc_id = db.Column(db.Integer,db.ForeignKey('doctor_model.id'))
    cat_id = db.Column(db.Integer,db.ForeignKey('cat_model.id'))









